home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr25 / tmbnk201.zip / TIMEBANK.CMD < prev   
OS/2 REXX Batch file  |  1993-03-03  |  9KB  |  244 lines

  1. /*                   TimeBank Version 2.01
  2.                        Rexx CMD file for a Time Bank for Maximus
  3.                                   by Edward Owens
  4.                                 of The Looking Glass
  5.                                   FidoNet 1:123/81
  6.  
  7. To run put the following line in your MENU.CTL file where you want it:
  8.  
  9. ReRead     Xtern_Run       Maxpipe_%P_TimeBank.cmd_%K     Normal "TimeBank"
  10.  
  11. Then replace the bbs and sysop variables immediately below  and put
  12. this CMD file in your Maximus directory.  You may modify this in any way
  13. your little heart's desires but do not distribute once modified.  This is a rough
  14. first chop there will be another version to follow with more features.  This
  15. is Freeware, there is no charge for it and I assume no responsibility for any
  16. damage it may do.  Have fun.*/
  17. echo off
  18. /* ansi on */
  19. bbs="The Looking Glass"  /* Replace with the name of your bbs */
  20. sysop="Fast ED's" /* Replace with your name or handle */
  21. maxtime=120  /* Maximum amount of time on account */
  22. deptime=30   /* Maximum time deposit per day */
  23. withtime=30   /* Maximum time withdrawal per day */
  24. maxbytes=3000   /* Maximum Kbytes on account  */
  25. depbytes=300   /* Maximum Kbytes deposit per day  */
  26. withbytes=300   /* Maximum Kbytes withdrawal per day  */
  27. timeint=10   /* Interest rate per 30 days on time accounts  */
  28. byteint=10   /* Interest rate per 30 days on byte accounts  */
  29. /*  userfile='lastuser.bbs'   */
  30. userfile=INSERT(arg(1),'lastus.bbs',6)  /* Replace with above line if single node */
  31. CLS
  32. say
  33. say
  34. say '            ********************************'
  35. say '            *     Welcome to TimeBank      *'
  36. say '            *       by Edward Owens        *'
  37. say '            *      FidoNet  1:123/81       *'
  38. say '            *   Written in REXX for OS/2   *'
  39. say '            ********************************'
  40. say '1H'
  41. say 'Reading account information.......'
  42. bankfile='timebank.dat'
  43. usedbytes=0
  44. privbytes=0
  45. position=1
  46. name=STRIP(CHARIN(userfile,1,36),,'00'x)
  47. timeleft=C2D(CHARIN(userfile,111,1)) + (C2D(CHARIN(userfile,112,1)) * 256)
  48. priv=9-C2D(CHARIN(userfile,141,1))
  49. if priv=-1 then priv=0
  50. if priv<-1 then priv=10
  51. do x=212 to 211 by -1
  52.    usedbytes=(usedbytes * 256) + C2D(CHARIN(userfile,x,1))
  53. end  /* do */
  54. call LINEOUT(userfile)
  55. if usedbytes>32767 then usedbytes=usedbytes-65536
  56. do x=325+(priv*14) to 324+(priv*14) by -1
  57.    privbytes=(privbytes * 256) + C2D(CHARIN('max.prm',x,1))
  58. end  /* do */
  59. call LINEOUT('max.prm')
  60. bytes=privbytes-usedbytes
  61. num=0
  62. DO UNTIL (name=SUBWORD(acct.num,1,2)) | (LINES(bankfile)=0)
  63.    num=num + 1   
  64.    acct.num=LINEIN(bankfile)
  65. end /* do */
  66. if (LINES(bankfile)=0) & \(name = SUBWORD(acct.num,1,2)) then do
  67.    banktime=0
  68.    bankbytes=0
  69.    ttime=withtime
  70.    tbytes=withbytes
  71.    okfile=LINEOUT(bankfile,name DATE(S) banktime bankbytes withtime withbytes)
  72.    call LINEOUT(bankfile)
  73. end /* if */
  74. else  do
  75.    call LINEOUT(bankfile)
  76.    banktime=WORD(acct.num,4)
  77.    bankbytes=WORD(acct.num,5)
  78.    if DATE(S) = WORD(acct.num,3) then do
  79.       ttime=WORD(acct.num,6)
  80.       if ttime='' then ttime
  81.       tbytes=WORD(acct.num,7)
  82.       deptime=deptime+withtime-ttime
  83.       withtime=ttime
  84.       depbytes=depbytes+withbytes-tbytes
  85.       withbytes=tbytes
  86.    end /* if */
  87.    else do
  88.       day=WORD(acct.num,3)
  89.       today=DATE(S)
  90.       
  91. days=((LEFT(today,4)-LEFT(day,4))*360)+((SUBSTR(today,5,2)-SUBSTR(day,5,2))*30)+RIGHT(today,2)-RIGHT(day,2)
  92.       inttime=((days*banktime*timeint)%3000)
  93.       intbytes=((days*bankbytes*byteint)%3000)
  94.       banktime=banktime+inttime
  95.       bankbytes=bankbytes+intbytes
  96.       say
  97.       say
  98.       say 'You have earned' inttime 'since last time on for a balance of' banktime
  99.       say 'You have earned' intbytes 'since last time on for a balance of' bankbytes
  100.       say
  101.       say 'Press any key for menu'
  102.       pull
  103.    end /* else */
  104. end /* else */
  105. CLS
  106. say
  107. say "    Welcome" name "to" sysop "Time Bank for Maximus OS/2"
  108. say
  109. say "            Deposit time"
  110. say "            Withdraw time"
  111. say "            Put some Kbytes in"
  112. say "            Get some Kbytes out"
  113. say "            Speedy deposit all"
  114. say "            Quit back to "bbs
  115. say
  116. DO UNTIL choice='Q'
  117. say '1H'
  118. say ''
  119. say ''
  120. say ''
  121. say ''
  122. say ''
  123. say '1H'
  124. say '    You have' banktime 'minutes on account and ' timeleft 'minutes left on BBS   '
  125. say '    You have' bankbytes 'Kbytes on account and ' bytes 'Kbytes left on BBS    '
  126. say
  127. say '            What would you like to do?'
  128. pull choice
  129. select
  130.    when choice='D' then do
  131.         say '    You have' banktime 'minutes on account and ' timeleft 'minutes left.'
  132.         say '    Maximum on account is' maxtime 'and maximum deposit is' deptime
  133.     say '    How much would you like to deposit?'
  134.         pull amount
  135.         if datatype(amount,'W') then do
  136.            if amount>timeleft then amount=timeleft
  137.            if amount>deptime then amount=deptime
  138.            if (amount+banktime>maxtime) then amount=maxtime-banktime
  139.            timeleft=timeleft-amount
  140.            banktime=banktime+amount
  141.            deptime=deptime-amount
  142.            withtime=withtime+amount
  143.            if timeleft=0 then choice='Q'
  144.         end
  145.    end
  146.    when choice='W' then do
  147.         say '    You have' banktime 'minutes on account and ' timeleft 'minutes left.'
  148.         say '    Maximum withdrawal is' withtime
  149.         say '    How much would you like to withdraw?'
  150.         pull amount
  151.         if datatype(amount,'W') then do
  152.            if amount>banktime then amount=banktime
  153.            if amount>withtime then amount=withtime
  154.            deptime=deptime+amount
  155.            withtime=withtime-amount
  156.            timeleft=timeleft+amount
  157.            banktime=banktime-amount
  158.         end
  159.    end
  160.    when choice='P' then do
  161.         say '    You have' bankbytes 'Kbytes on account and ' bytes 'Kbytes left.'
  162.         say '    Maximum on account is' maxbytes 'and maximum deposit is' depbytes
  163.     say '    How much would you like to deposit?'
  164.         pull amount
  165.         if datatype(amount,'W') then do
  166.            if amount>bytes then amount=bytes
  167.            if amount>depbytes then amount=depbytes
  168.            if (amount+bankbytes>maxbytes) then amount=maxbytes-bankbytes
  169.            depbytes=depbytes-amount
  170.            withbytes=withbytes+amount
  171.            bytes=bytes-amount
  172.            bankbytes=bankbytes+amount
  173.         end
  174.    end
  175.    when choice='G' then do
  176.         say '    You have' bankbytes 'Kbytes on account and ' bytes 'Kbytes left.'
  177.         say '    Maximum withdrawal is' withbytes
  178.         say '    How much would you like to withdraw?'
  179.         pull amount
  180.         if datatype(amount,'W') then do
  181.            if amount>bankbytes then amount=bankbytes
  182.            if amount>withbytes then amount=withbytes
  183.            depbytes=depbytes+amount
  184.            withbytes=withbytes-amount
  185.            bytes=bytes+amount
  186.            bankbytes=bankbytes-amount
  187.         end
  188.    end
  189.    when choice='S' then do
  190.         say 'Making maximum time deposit and byte deposit'
  191.         if timeleft>deptime then amount=deptime
  192.         else amount=timeleft
  193.         if (amount+banktime>maxtime) then amount=maxtime-banktime
  194.         say 'Deposited' amount 'minutes'
  195.         timeleft=timeleft-amount
  196.         banktime=banktime+amount
  197.         deptime=deptime-amount
  198.         withtime=withtime+amount
  199.         if bytes>depbytes then amount=depbytes
  200.         else amount=bytes
  201.         if (amount+bankbytes>maxbytes) then amount=maxbytes-bankbytes
  202.         say 'Deposited' amount 'Kbytes'
  203.         depbytes=depbytes-amount
  204.         withbytes=withbytes+amount
  205.         bytes=bytes-amount
  206.         bankbytes=bankbytes+amount
  207.         choice='Q'
  208.    end
  209. otherwise NOP
  210. end  /* select */
  211. end
  212. say
  213. say
  214. say 'Returning you to 'bbs''
  215. timeout = d2c(timeleft//256)
  216. okfile = CHAROUT(userfile,timeout,111)
  217. timeout = d2c(timeleft%256)
  218. okfile = CHAROUT(userfile,timeout,112)
  219. usedbytes=privbytes-bytes
  220. bytesout=d2c(0)
  221. if usedbytes<0 then do
  222.    bytesout=d2c(255)
  223.    usedbytes=65536+usedbytes
  224. end
  225.    okfile=CHAROUT(userfile,bytesout,214)
  226.    okfile=CHAROUT(userfile,bytesout,213)
  227. do x=211 to 212 by 1
  228.    bytesout= d2c(usedbytes//256)
  229.    usedbytes= usedbytes%256
  230.    okfile = CHAROUT(userfile,bytesout,x)
  231. end  /* do */
  232. 'ren' bankfile 'timebank.tmp'
  233. DO UNTIL (LINES('timebank.tmp')=0)
  234.    account=LINEIN('timebank.tmp')
  235.    if (name=SUBWORD(account,1,2)) then 
  236.       okfile=LINEOUT(bankfile,name DATE(S) banktime bankbytes withtime withbytes)
  237.    else okfile=LINEOUT(bankfile, account)
  238. end /* do */
  239. call LINEOUT(bankfile)
  240. call LINEOUT('timebank.tmp')
  241. 'del timebank.tmp'
  242. CLS
  243. return
  244.